package com.sx.ad.utils;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.function.Supplier;

/**
 * @author zkx
 * @Date 2024/9/11 10:37
 */
@Slf4j
public class CommonUtils {

	public static <K, V> V getOrCreate(K key, Map<K, V> map, Supplier<V> factor) {
		return map.computeIfAbsent(key, k -> factor.get());
	}

	public static String stringConcat(String... args) {
		StringBuilder result = new StringBuilder();
		for (String arg : args) {
			result.append(arg.trim());
			result.append("-");
		}
		result.deleteCharAt(result.length() - 1);
		return result.toString();
	}
}
